<?php
namespace WDB\WebUI\User;
use WDB;
/**
 * Description of ImageColumnWebUI
 *
 * @author Richard Ejem <r dot ejem at seznam-cz>
 */
class ImageColumnWebUI extends WDB\WebUI\Column{
    
    public function getDetailedHTML(WDB\Wrapper\iRecord $record)
    {
        if (file_exists($this->columnWrapper->getFileName($record)))
        {
            $hash = substr(md5_file($this->columnWrapper->getFileName($record)), 0, 10);
            return '<img src="'.htmlspecialchars($this->columnWrapper->getUrl($record)).'?'.$hash.'" alt="" />';
        }
        else
        {
            return '-žádný obrázek-';
        }
    }
    
    public function getEditingHTML(WDB\Wrapper\iRecord $record)
    {
        return $this->getDetailedHTML($record).'<input type="file" name="'.$this->name.'" />';
    }
    
    public function getTitle()
    {
        return $this->columnWrapper->getTitle();
    }

}